Partial Class GTSWeb_Shipment_Manage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim BranchInfo As New GTSDAL.ClientBranchINFODataTable
        BranchInfo = GTSSystem.BLL.ClientBranch.getClientBranchInfo(Profile.BranchId)
        If Not IsPostBack Then
            txtShipmentDate.Text = Date.Today
            txtOriginAddress.Text = BranchInfo.Rows(0).Item("StreetAddress")
            txtOriginpostalCode.Text = BranchInfo.Rows(0).Item("PostalCode")
            If (Profile.RateLocationID <> Nothing) Then
                ddlOriginCity.SelectedValue = Profile.RateLocationID
            End If
        End If
    End Sub

    Protected Sub lnkbtnCreateShipment_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkbtnCreateShipment.Click
        Dim Shipmentdate As Date
        Dim CarrierID As Integer = 1
        Dim SurchargeId As Integer

        Dim RateOriginLocationID As Integer
        Dim OriginAddress As String
        Dim OriginPostalCode As String

        Dim RateDestinationLocationID As Integer
        Dim DestinationAddress As String
        Dim DestinationPostalCode As String
        Dim ServiceTypeId As Integer
        Dim Description As String
        Dim ShipmentNumber As Integer
        Dim ShipmentMgrs As New GTSSystem.BLL.Shipment

        Try
            Shipmentdate = Convert.ToDateTime(txtShipmentDate.Text)

            DestinationAddress = txtDestinationAddress.Text
            RateDestinationLocationID = Convert.ToInt32(ddlDestinationRateLocation.SelectedValue)
            DestinationPostalCode = txtDestinationPostalCode.Text

            OriginAddress = txtOriginAddress.Text
            RateOriginLocationID = Convert.ToInt32(ddlOriginCity.SelectedValue)
            OriginPostalCode = txtOriginpostalCode.Text

            ServiceTypeId = Convert.ToInt32(ddlServiceTypeID.SelectedValue)
            Description = txtDescription.Text
            ShipmentNumber = Convert.ToInt32(txtShipmentNumber.Text)

            SurchargeId = Convert.ToInt32(ddlSurcharge.SelectedValue)

            ShipmentMgrs.CreateShipment(Shipmentdate, Profile.ClientId, Profile.BranchId, CarrierID, 0, RateOriginLocationID, OriginAddress, OriginPostalCode, RateDestinationLocationID, DestinationAddress, DestinationPostalCode, ServiceTypeId, Description, 0, 0, 0, SurchargeId, 0, Profile.UserName, 1, ShipmentNumber, 0, 0)
            lblMessage.Text = "Shipment successfully added."
            Response.Redirect(Request.Url.ToString, False)
        Catch ex As Exception
            lblMessage.Text = "System Error: Unable to process your request" + ex.Message
        End Try
    End Sub
End Class
